<template>
  <div class='xtx-goods-page'>
    <div class="container" v-if='detail' >
      <!-- 面包屑 -->
      <!-- <XtxBread>
        <XtxBreadItem to="/">首页</XtxBreadItem>
        <XtxBreadItem to="/">手机</XtxBreadItem>
        <XtxBreadItem to="/">华为</XtxBreadItem>
        <XtxBreadItem to="/">p30</XtxBreadItem>
      </XtxBread> -->
      <!-- 商品信息 -->
      <div class="break-crumb">
        <span>首页 > </span>
        <span>{{ detail.categories[1].name }} ></span>
        <span>{{ detail.categories[0].name }} ></span>
        <span>{{ detail.name}}</span>
      </div>
      <div class="goods-info">
      <!-- 左侧图片展示 -->
         <div class="media">
         <GoodsImage :images="detail.mainPictures"/>
         <!--  当前商品信息 -->
         <GoodsSales/>
         </div>
<!-- 右侧商品操作 -->
         <div class="spec">
           <!--  配送信息 -->
           <GoodsName :detail="detail"/>
         </div>
      </div>
      <!-- 商品推荐 -->
      <GoodsRelevant />
      <!-- 商品详情 -->
      <div class="goods-footer">
        <div class="goods-article">
          <!-- 商品+评价 -->
          <div class="goods-tabs"></div>
          <!-- 注意事项 -->
          <div class="goods-warn"></div>
        </div>
        <!-- 24热榜+专题推荐 -->
        <div class="goods-aside"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { findGoods } from '@/api/product'
import GoodsRelevant from './components/goods-relevant.vue'
import GoodsImage from './components/goods-image.vue'
import GoodsSales from './components/goods-sales.vue'
import GoodsName from './components/goods-name.vue'
import { useRoute } from 'vue-router'
import { ref } from 'vue'
export default {
  name: 'XtxGoodsPage',
  components: { GoodsRelevant, GoodsImage, GoodsSales, GoodsName },
  setup () {
    const router = useRoute()
    const detail = ref(null)
    findGoods(router.params.id).then(ret => {
      if (ret.result) { // 当数据请求回来再赋值以供模版使用
        detail.value = ret.result
      }
    })
    return { detail }
  }
}
</script>

<style scoped lang='less'>
.goods-info {
  min-height: 600px;
  background: #fff;
  display: flex;
  .media {
    width: 580px;
    height: 600px;
    padding: 30px 50px;
  }
  .spec {
    flex: 1;
    padding: 30px 30px 30px 0;
  }
}
.goods-footer {
  display: flex;
  margin-top: 20px;
  .goods-article {
    width: 940px;
    margin-right: 20px;
  }
  .goods-aside {
    width: 280px;
    min-height: 1000px;
  }
}
.goods-tabs {
  min-height: 600px;
  background: #fff;
}
.goods-warn {
  min-height: 600px;
  background: #fff;
  margin-top: 20px;
}
</style>
